#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <net/route.h>
#include <netinet/inet.h>
#include <iwconfig.h>
#include "cmd.h"
#include "raven.h"
#include "server.h"

Data Structures | |
| struct | cmd_desc |
| shell command structure More... | |
Defines | |
| #define | MIN(x, y) ((x<y)?x:y) |
| simple macro that returns the smaller of two values | |
Typedefs | |
| typedef int | cmd_fun_t (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| shell command helper function type | |
| typedef struct cmd_desc | cmd_desc_t |
Functions | |
| int | help_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| function decalarations | |
| int | ledOn_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that turns on the LED | |
| int | ledOff_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that turns off the LED | |
| int | blink_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that sets the number of blinks in the blink interval | |
| int | lcd_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that prints a message to the LCD | |
| int | temp_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that samples the temperature using the onboard sensor | |
| int | time_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that prints the local time at the raven | |
| int | rte_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that prints the route information | |
| int | if_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that invokes iwconfig() with option STATUS to get the wireless interface information | |
| int | exit_fun (char *msg, char *buf, int curindex, int len, int16_t sockfd) |
| helper function that closes the TCP connection by returning -1 | |
| void | iwconfig_status_handler (event_t event, void *cbargs, void *context) |
| callback for iwconfig() invoked with STATUS flag | |
| void | prompt (int16_t sockfd) |
| this function sends a prompt to a TCP socket | |
| uint8_t | skip (char *str, uint8_t i, uint8_t e, char *skips) |
| Skip over chars. | |
| int | processCmd (char *cmd, int curindex, int len, int16_t sockfd) |
| process shell command | |
Variables | |
| cmd_desc_t | cmd_table [] |
| data base of supported shell commands | |
| static net_device_info_t | fs_lpan0_info |
| Network interface information from iwconfig. | |
| static int16_t | fs_sockfd |
| file scope socket descriptor | |
| #define MIN | ( | x, | |||
| y | ) | ((x<y)?x:y) |
simple macro that returns the smaller of two values
| typedef struct cmd_desc cmd_desc_t |
| typedef int cmd_fun_t(char *msg, char *buf, int curindex, int len, int16_t sockfd) |
shell command helper function type
| int blink_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that sets the number of blinks in the blink interval
blink_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int exit_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that closes the TCP connection by returning -1
exit_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |
| int help_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
function decalarations
helper function that prints the help text at the prompt
help_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int if_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that invokes iwconfig() with option STATUS to get the wireless interface information
if_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| void iwconfig_status_handler | ( | event_t | event, | |
| void * | cbargs, | |||
| void * | context | |||
| ) |
callback for iwconfig() invoked with STATUS flag
iwconfig_status_handler
| event | equals to IWCONFIG as this is a iwconfig() STATUS callback | |
| cbargs | passes dev_info back from iwconfig() STATUS call | |
| context | passes context back from iwconfig() STATUS call |

| int lcd_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that prints a message to the LCD
lcd_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int ledOff_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that turns off the LED
ledOff_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int ledOn_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that turns on the LED
ledOn_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int processCmd | ( | char * | cmd, | |
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
process shell command
processCmd
Process command in command buffer cmd[] starting at cmd[curindex] and ending at cmd[len] Dispatches to individual command handlers
| cmd | is the pointer to the string of shell command | |
| curindex | is always zero | |
| len | is the number of characters in the shell command | |
| sockfd | is the TCP socket descriptor |
negative integers : Close

| void prompt | ( | int16_t | sockfd | ) |
this function sends a prompt to a TCP socket
prompt
| sockfd | is the descriptor of the socket |

| int rte_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that prints the route information
rte_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| uint8_t skip | ( | char * | str, | |
| uint8_t | i, | |||
| uint8_t | e, | |||
| char * | skips | |||
| ) |
Skip over chars.
skip
| str | is the pointer to the string to process (skip) | |
| i | is the starting position within str | |
| e | is the length of the str | |
| skips | is a pointer to the array of characters to stop on |
-1 if none encountered
| int temp_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that samples the temperature using the onboard sensor
temp_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

| int time_fun | ( | char * | msg, | |
| char * | buf, | |||
| int | curindex, | |||
| int | len, | |||
| int16_t | sockfd | |||
| ) |
helper function that prints the local time at the raven
time_fun
| msg | is a pointer to the response message | |
| buf | is a pointer to the shell command received | |
| curindex | is the starting position of the shell command argument within buf | |
| len | is the total length of the shell command (command + argument) | |
| sockfd | is the socket descriptor |

Initial value:
{
{help_fun, "?", "print cmds"},
{ledOn_fun, "lon", "LED on"},
{ledOff_fun, "loff", "LED off"},
{blink_fun, "blink", "Blink N"},
{lcd_fun, "lcd", "display msg"},
{temp_fun, "temp", "display temp"},
{time_fun, "time", "time of day"},
{rte_fun, "route", "info"},
{if_fun, "ifconfig", "IP config"},
{exit_fun, "exit", "exit shell"}
}
net_device_info_t fs_lpan0_info [static] |
Network interface information from iwconfig.
int16_t fs_sockfd [static] |
file scope socket descriptor
1.5.5